// cloudfunctions/request/index.js
const cloud = require('wx-server-sdk');
cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
});
exports.main = async (event, context) => {
    try {
        const {
            url
        } = event;
        if (!url) {
            throw new Error('缺少 url 参数');
        }

        const result = await cloud.request({
            url
        });
        return result.data;
    } catch (error) {
        console.error('request 云函数错误:', error);
        return {
            errcode: -1,
            errmsg: error.message || '请求失败'
        };
    }
};